Microcontroller

ABSTRACT

A microcontroller comprises a clock control circuit provided with a clock mode designation register for storing clock frequency information corresponding to an extremely low speed mode for an operation by a clock of an extremely low frequency, or a normal operation mode for operation by a clock of a normal frequency, which outputs a first control signal in accordance with a value set in the clock mode designation register when the extremely low speed mode is designated during an operation on the normal operation mode, a DRAM for holding, on the extremely low speed mode, data by being operated on a self-refresh mode, and outputting a confirmation signal indicating transfer to the self-refresh mode, a DRAM control circuit for transferring the DRAM to the self-refresh mode based on the first control signal, a ROM operated on the extremely low speed mode, a remap control circuit for controlling an address changing circuit based on the confirmation signal outputted form the DRAM, and outputting a second control signal for switching a program execution address from the DRAM to an address of the ROM to control an address space in which a program is executed, and the address changing circuit for switching the address space based on the second control signal.

FIELD OF THE INVENTION

[0001] The present invention relates to a microcontroller provided with a control function to enable switching between a normal operation mode for operating a microprocessor by a normal clock frequency, and an extremely low speed operation mode for operating the microprocessor by an extremely low speed clock frequency.

BACKGROUND OF THE INVENTION

[0002] In recent years, along with the popularization of portable devices such as a mobile telephone, a need has arisen to operate a microprocessor at low power consumption for a long time, and attention has been drawn to a technology for prolonging a battery life, and dynamically changing an operation clock of the microprocessor in accordance with its operation mode to achieve low power consumption. However, promotion of a low speed of a clock frequency has increased effects on the portable devices. For example, a DRAM which is a mainstream memory at present must be refreshed by a fixed frequency or higher, and thus it cannot be operated by an extremely low speed clock of this frequency or lower.

[0003]FIG. 1 shows a constitutional example of a conventional microprocessor having an extremely low speed mode. A CPU 415, a DRAM 402, an SRAM 403, an interrupt control circuit 416, and a clock control circuit incorporating a clock mode designation register 405 are connected to a data bus 401. A not-shown ROM is also connected.

[0004] As the DRAM 402 holds data by using a very small capacitor, the data is lost unless a refreshing operation is periodically executed to save the data. If there is a lowest clock frequency for this refreshing, and a supplied clock frequency is lower than the lowest frequency, the DRAM 402 must be operated by a self-refresh mode to hold the data.

[0005] The SRAM 403 is operated at a low speed by low voltage. However, a price is high because of a large pattern area per bit, and there is a limit, i.e., only a small-capacity SRAM can be loaded on a chip such as a microprocessor.

[0006] A command queue 404 is normally constituted of first in, first out (FIFO), stores commands to be executed in order, and sends a command to be executed next to a command register IR 406. A program counter 409 is a register for designating an address of the command to be executed next, and counts in accordance with the number of bytes of the command. The address is outputted to an address bus 410, and an address DramAdr of the DRAM 402, and an address SramAdr of the SRAM 403 are supplied. An address Rom Adr of the ROM is also supplied.

[0007] Normally, as a method for transferring the DRAM 402 to an extremely low speed mode, there is a method for setting a value corresponding to an operation mode in the clock mode designation register 405 to transfer the CPU to the extremely low speed mode by the clock control circuit 407. Upon reception of the designation, the clock control circuit 407 supplies a clock of a frequency corresponding to the designation to each part of the microcontroller. After the clock control circuit 407 enters an extremely low speed clock mode designation signal ModeReq to a DRAM control circuit 408, the DRAM control circuit 408 transfers the DRAM to a self-refresh mode.

[0008] The interrupt control circuit 416 receives an interrupt request signal IntReq from the inside or the outside, and then outputs an interrupt signal Int to the CPU 415. Upon reception of the request, the CPU 415 jumps to an interrupt processing routine to execute processing in accordance with an interrupt factor thereof. Regarding interrupt factors, interruption by an internal factor, for example interruption when a command inexcutable because of a memory abnormality is executed, or interruption by an, external factor, for example timer interruption, interruption from a keyboard or the like, is conceivable. Here, the interruption is used to return the CPU 415 operated by an extremely low speed mode to a normal operation mode.

[0009] Now, description is made of a process until the conventional microcontroller shown in FIG. 1 is operated by an extremely low speed clock. FIG. 2 is a conceptual diagram showing an address space where the conventional microcontroller of FIG. 1 is operated. In FIG. 2, in the address space, addresses start from a lowest address of 0x0000, and a highest address is 0xffff. A program originally placed on the ROM is copied in the DRAM by a loader, and executed at a high speed. However, as the DRAM is transferred to a self-refresh mode by an extremely low speed clock, the execution of the program becomes impossible in this state. Thus, to transfer to an extremely low speed mode, the operation is jumped to an extremely low speed mode transfer routine in the SRAM 403. That is, the operation is jumped from an address Dram Adr of a jump command in the DRAM to a head address SramAdr of the extremely low speed mode transfer routine in the SRAM. In the extremely low speed mode transfer routine, processing necessary for the transfer is executed, and the program is executed in the SRAM until the mode is released. Thus, the program in the SRAM can be set identical to the program in the DRAM. The extremely low speed mode can be released by a command in the SRAM, or an interrupt routine for the CPU 415. However, this interrupt routine must be loaded on the SRAM. Another method for transfer to an extremely low speed mode is to jump an operation to a ROM operated even by an extremely low speed clock. In this case, the operation is jumped to a head address RomAdr of a corresponding processing routine in the ROM.

[0010] On the conventional extremely low speed mode, the SRAM 403 high in price, small in capacity, and unloadable on the chip has often been used. Even if copies of almost all the programs in the DRAM can be loaded on the SRAM 403, a consumed capacity of the SRAM becomes impractically considerable. In addition, a method of installing the SRAM outside the microcontroller is expensive, and a system becomes complex. Use of a ROM in this respect is inexpensive, and a large capacity is easily achieved.

[0011] However, in all of the above-described methods, a considerable number of processing steps must be executed to transfer between the extremely low speed mode and the normal mode and, therefore, immediacy is lost. This is described more in detail by way of specific example. For example, if there is a need to take out data because of an external factor (high speed data reception) during operation on an extremely low speed mode, interrupt processing is executed to return to a normal operation mode, and then data is received by an operation on the normal mode. In this case, until the return to the normal mode (e.g., operation mode by a clock of 20 MHz), a program is executed by an extremely low speed mode (e.g., operation mode by a clock of 2 MHz). Thus, assuming that an interrupt processing routine is constituted of commands of thirty steps, and processing to return to the normal mode is constituted of commands of twenty steps, time of 25 μS is expended on the extremely low speed mode. If there are serial communications executed at 500 Kbps (data cycle 20 μS when a data length is 8 bits, and each of start and stop bits is 1), communication errors occur on the extremely low speed mode.

[0012] Thus, if the conventional operation mode transfer processing between the extremely low speed mode and the normal operation mode is executed by software interrupt processing, immediacy is lost to disable completion of processing in time, creating a problem of erroneous operations.

SUMMARY OF THE INVENTION

[0013] The present invention provides a microcontroller capable of executing operation mode transfer between an extremely low speed mode and a normal operation mode without losing immediacy. Thus, a microcontroller of the present invention comprises a clock control circuit provided with a clock mode designation register for storing clock frequency information corresponding to an extremely low speed mode for an operation by a clock of an extremely low frequency, or a normal operation mode for operation by a clock of a normal frequency, which outputs a first control signal in accordance with a value set in the clock mode designation register when the extremely low speed mode is designated during an operation on the normal operation mode, a DRAM for holding, on the extremely low speed mode, data by being operated on a self-refresh mode, and outputting a confirmation signal indicating transfer to the self-refresh mode, a DRAM control circuit for transferring the DRAM to the self-refresh mode based on the first control signal, a ROM operated on the extremely low speed mode, a remap control circuit for controlling an address changing circuit based on the confirmation signal from the DRAM, and outputting a second control signal for switching a program execution address from the DRAM to an address of the ROM to control an address space in which a program is executed, and the address changing circuit for switching the address space based on the second control signal.

[0014] The microcontroller of the present invention further comprises an interrupt control circuit, wherein during an operation on the extremely low speed mode, when an interrupt signal indicating return to the normal operation mode is entered to the interrupt control circuit, the interrupt control circuit rewrites the value of the clock mode designation register to clock information corresponding to the normal operation mode to cause the clock control circuit to invalidate the first control signal, the DRAM control circuit accordingly releases the self-refresh mode of the DRAM, and notifies invalidation of the confirmation signal to the remap control circuit and, upon reception of the notice, the remap control circuit switches the second control signal to control the address changing circuit, and change a program execution address from the ROM to an address of the DRAM.

BRIEF DESCRIPTION OF THE DRAWINGS

[0015]FIG. 1 is constitutional view of a conventional microcontroller;

[0016]FIG. 2 is an explanatory view of an address space in the conventional microcontroller;

[0017]FIG. 3 is a constitutional view of a microcontroller of a specific example according to the present invention;

[0018]FIG. 4 is an explanatory view of an address space in the specific example of the present invention;

[0019]FIG. 5 is a flowchart of operation mode transition in the specific example of the present invention; and

[0020]FIG. 6 is a constitutional view of an interrupt control circuit in the specific example of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0021] Next, detailed description will be made of a specific example of the present invention with reference to the accompanying drawings.

[0022]FIG. 3 shows a constitutional example of a microprocessor of a specific example according to the present invention. A CPU 115, a DRAM 102, A ROM 103, an interrupt control circuit 116, and a clock control circuit 107 incorporating a clock mode designation register 105 are connected to a data bus 101, and a not-shown SRAM or the like is also connected.

[0023] The DRAM 102 is basically similar to that of FIG. 1, but different in that it outputs a confirmation signal of transfer to a self-refresh mode with respect to a ModeReq signal outputted from the clock control circuit 107 upon reception of designation of the clock mode designation register 105.

[0024] The ROM 103 is operated by low voltage, and a pattern area per bit is small. Thus, it can be set to a large capacity.

[0025] A command queue 104 is normally constituted of FIFO, stores commands to be executed in order, and sends a command to be executed next to a command register IR 106. This command queue 104 includes a control circuit.

[0026] A remap control circuit 111 in the specific example has a function for controlling transfer between a DRAM and a ROM mainly in an address space. FIG. 4 is an explanatory view of the address space in the specific example. The remap control circuit 111 receives a confirmation signal ModeAck of transfer of the DRAM 102 to an extremely low speed mode (self-refresh mode), and then outputs a signal Romsel for controlling a multiplexer MPX 112 in an address changing circuit 114.

[0027] The signal Romsel is for selecting an offset address ofsAdr or “0” at the multiplexer MPX 112. If the offset address ofsAdr is selected, an execution address is transfers to the DRAM 102. If “0” is selected, an execution address is transferred to the ROM 103. Such transfer is made for the purpose of executing a program in the ROM 103 when the RomSel signal is invalid (i.e., “0” is selected) during resetting such as power-on-resetting.

[0028] A separately installed loader or a loader in the ROM copies the program of the ROM in the DRAM 102, and transfers control to the DRAM 102 to execute the program at a high speed. Accordingly, as shown in FIG. 4, there are programs of identical contents side by side in the address space, which are separated by the offset address ofsAdr.

[0029] In the specific example, ClkCrt outputted from the remap control circuit 111 is entered to the clock control circuit 107, and used for actually transferring a clock from an extremely low speed to a normal speed, or controlling its reverse operation.

[0030] Addition of the above-described offset address ofsAdr or the like is executed by an adder ADD 113, and its added value is outputted to the address bus 110, whereby an address DramSdr in the DRAM 102 and an address RomAdr in the ROM 103 are supplied. Even if there is a jump command in the command queue 104, in the specific example, since an address of the command is not directly set in a program counter, no problems occur irrespective of a relative or absolute address.

[0031] In the conventional microcontroller shown in FIG. 1, since the transfer routine from the extremely low speed mode to the normal mode is executed in the ROM, immediacy is lost in the transfer to create problems such as communication errors. However, according to the specific example, processing from designation of transfer to the normal mode to actual transfer to this mode can be executed within delay time of a gate level.

[0032] By a command lastly executed in the DRAM 102, information regarding a clock frequency corresponding to the extremely low speed mode is set in the clock mode designation register 105. Then, the clock control circuit 107 enters an extremely low speed mode designation signal ModeReq to a DRAM control circuit 108, and the DRAM 102 receives this designation to transfer to the extremely low speed mode.

[0033] The DRAM control circuit 108 outputs a confirmation signal ModeAck to notify completion of the transfer. No new commands are executed in a period from reception of mode changing instruction to actual transfer of an operation clock frequency to an extremely low speed frequency to output the confirmation signal, and all the above operations are finished within delay time of a hardware gate level. Thus, a next command of an address RomAdr=DramAdr-ofsAdr+1 in the ROM can be executed with respect to a last command address DramAdr in the DRAM 102.

[0034] If the gate processing delay time cannot take sufficient spare time for an operation clock cycle, a command having standby time may be executed in the CPU. However, since the transfer to the extremely low speed mode has been completed, sufficient room is normally generated for command reading from the ROM 103.

[0035] The specific example is characterized in that when the operation is returned from the extremely low speed mode to the normal mode, no interruption is executed with the CPU 115 but a ClkRegWr signal for rewriting held data is outputted from the interrupt control circuit 116 to the clock mode designation register 105 in the clock control circuit 107.

[0036] As described above in the background of the invention, if there is no time for executing software interruption with the CPU which executes the program in the ROM on the extremely low speed mode, the interrupt control circuit 116 which receives an interrupt request signal IntReq determines its factor by an internal interrupt factor determination circuit 617 (see FIG. 6), and outputs a control signal ClkRegWr. By this signal, the data held in the clock mode designation register 105 is rewritten to be data corresponding to the normal mode.

[0037]FIG. 6 is a constitutional view of the interrupt control circuit 116 according to an embodiment of the present invention. In this interrupt control circuit 116, an interrupt request identification circuit 617 which receives an interrupt request signal InReq outputs two signals in accordance with a type of interruption, and priority. In the case of a first signal Int 1, an interrupt enable signal IntEn is received from an interrupt enable flag 618, and an interrupt signal is outputted as an output of a gate G1 to the CPU 115. This is normal interruption.

[0038] On the other hand, in the case of a second output Int 2, a clock changing enable signal ClkChgEn is received from a clock changing enable flag 619 and, as an output of a gate G2, a signal ClkRegWr for controlling the clock mode designation register 105 is outputted. The interrupt signals Int and ClkRegWr are independent of each other, and thus an interrupt routine and an extremely low speed clock can be independently set in the CPU 115. Therefore, the microcontroller of the specific example can process the interrupt routine on a normal clock mode after return from the extremely low speed mode to the normal operation mode.

[0039] The following process is carried out in order to return from the extremely low speed mode for executing the command in the ROM 103 to the normal operation mode for executing the command in the DRAM 102. By a last command in the ROM 103, a value is set in the clock mode designation register 105 to release the extremely low speed mode. Then, the clock control circuit 107 invalidates an extremely low speed mode designation signal ModeReq to the DRAM control circuit 108. In response, the DRAM control circuit 108 releases the extremely low speed mode (self-refresh mode) of the DRAM, and invalidates a confirmation signal ModeAck to notify completion of the releasing. After the invalidation of the confirmation signal, the remap control circuit 111 switches a control signal Romsel of the multiplexer MPX 112 of the address changing circuit 114 to select an address ofsAdr, and controls the address to be switched to an address in the DRAM 102. A control signal ClkCtr is entered to the clock control signal 107, and a clock frequency is returned to a normal clock frequency.

[0040]FIG. 5 is a flowchart showing operation mode transition according to the embodiment of the present invention. After a start (301), the CPU executes the loader in the ROM, copies a content of the ROM in the DRAM 102, and transfers control to the DRAM. Thus, according to the embodiment, an operation mode immediately after resetting is not an extremely low speed mode. Then, a normal operation mode is continued until the extremely low speed mode is designated (302). If there is operation mode changing designation in step S302, in step S303, determination is made as to whether the extremely low speed mode is designated or not and, in accordance with its result, the processing is branched.

[0041] First, if the designation of the extremely low speed mode is determined, the DRAM 102 transfers to a self-refresh mode (304). Upon reception of a confirmation signal ModeAck thereof, the remap control circuit 111 outputs a control signal to cause the address changing circuit 114 to select an offset address “0”, and as a result a program is executed in the ROM 103 (306).

[0042] If the designation of the extremely low speed mode is not determined in step 303, i.e., return to the normal mode is designated, the DRAM 102 releases the self-refresh mode (307). After invalidation of the confirmation signal ModeAck, the remap control circuit 111 switches a control signal to cause the address changing circuit to select an offset address ofsAdr (308). As a result, a program is executed again in the DRAM 102 (309).

[0043] As described above in detail, according to the present invention, the microcontroller comprises the DRAM for holding, on the extremely low speed mode, data by being operated on the self-refresh mode, the DRAM control circuit for controlling the operation mode of the DRAM, the ROM operated on the extremely low speed mode, the clock control circuit provided with the clock mode designation register for storing the clock frequency information corresponding to the extremely low speed mode or the normal operation mode, the remap control circuit for controlling the address space in which the program is executed, and the address changing circuit. When the extremely low speed mode is designated on the normal operation mode, by setting a value corresponding to the extremely low frequency in the clock mode designation register, based on the first control signal outputted from the clock control circuit, the DRAM control circuit transfers the DRAM to the self-refresh mode, and outputs the confirmation signal indicating the transfer of the transfer of the DRAM to the self-refresh mode. The remap control circuit controls the address changing circuit based on the confirmation signal, and outputs the second control signal for switching the program execution address from the DRAM to the address of the ROM. The microcontroller of the present invention further comprises the interrupt control circuit, wherein during the operation on the extremely low speed mode, when the interrupt signal indicating return to the normal operation mode is entered to the interrupt control circuit, the interrupt control circuit rewrites the value of the clock mode designation register to be the clock information corresponding to the normal operation mode to cause the clock control circuit to invalidate the first control signal, the DRAM control circuit accordingly releases the self-refresh mode of the DRAM, and notifies invalidation of the confirmation signal to the remap control circuit and, upon reception of the notice, the remap control circuit switches the second control signal to control the address changing circuit, and change the program execution address from the ROM to the address of the DRAM. Therefore, even if transfer is made to the extremely low speed mode, and the DRAM is operated on the self-refresh mode, and thus unable to operate as a normal memory, the program can be executed in the ROM without much use of an expensive SRAM. Moreover, since the time of transfer from the normal mode to the extremely low speed mode is equal to gate delay time, execution on the extremely low speed mode is possible from a next command. The same applies to the return from the extremely low speed mode to the normal mode. 

What is claimed is:
 1. A microcontroller comprising: a clock control circuit provided with a clock mode designation register for storing clock frequency information corresponding to an extremely low speed mode for an operation by a clock of an extremely low frequency, or a normal operation mode for operation by a clock of a normal frequency, which outputs a first control signal in accordance with a value set in the clock mode designation register when the extremely low speed mode is designated during an operation on the normal operation mode; a DRAM for holding, on the extremely low speed mode, data by being operated on a self-refresh mode, and outputting a confirmation signal indicating transfer to the self-refresh mode; a DRAM control circuit for transferring the DRAM to the self-refresh mode based on the first control signal; a ROM operated on the extremely low speed mode; a remap control circuit for controlling an address changing circuit based on the confirmation signal, and outputting a second control signal for switching a program execution address from the DRAM to an address of the ROM to control an address space in which a program is executed; and the address changing circuit for switching the address space based on the second control signal.
 2. The microcontroller according to claim 1, wherein when the extremely low speed mode is designated, the address changing circuit is controlled in a manner that the first and second control signals and the confirmation signal are outputted while one command in the DRAM is executed to set a value in the clock mode designation register, and a command next to the one command is executed in the ROM based on the second control signal.
 3. The microcontroller according to claim 1, further comprising an interrupt control circuit, wherein during an operation on the extremely low speed mode, when an interrupt signal indicating return to the normal operation mode is entered to the interrupt control circuit, the interrupt control circuit rewrites the value of the clock mode designation register to be clock information corresponding to the normal operation mode to cause the clock control circuit to invalidate the first control signal, the DRAM control circuit accordingly releases the self-refresh mode of the DRAM, and notifies invalidation of the confirmation signal to the remap control circuit and, upon reception of the notice, the remap control circuit switches the second control signal to control the address changing circuit, and change a program execution address from the ROM to an address of the DRAM. 